﻿
Ext.namespace('FantastPlatform', 'FantastPlatform.UI');
FantastPlatform.UI.FlowImplementGrid = function (config) {

    Ext.apply(this, config);

    var fileStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '../Service/FlowFlowViewService.aspx?Action=SearchImplement'

        }),
        reader: new Ext.data.JsonReader({
            root: 'topics',
            totalProperty: 'totalCount',
            id: 'Id',
            fields: ['Id', 'Name', 'Description', 'Status', 'LevelId', 'Level', 'Leader', 'PersonNumber', 'StartTime', 'EchelonNumber', 'EndTime']
        }),
        remoteStore: true
    });

    this.store = fileStore;
    var self = this;   
    var paperBar = new FantastPlatform.Common.PapeToolBar({
        store: fileStore,
        noSort: true,
        defaultNum: 21
    });
    this.paperBar = paperBar;
    this.bbar = paperBar;
    this.pageNumber = paperBar.pageSize;

    var nm = new Ext.grid.RowNumberer();
    var sm = new Ext.grid.CheckboxSelectionModel();

    this.columns = [nm, sm, {
        header: 'Id',
        dataIndex: 'Id',
        hidden: true
    }, {
        header: 'LevelId',
        dataIndex: 'LevelId',
        hidden: true
    }, {
        header: '预案名称',
        dataIndex: 'Name',
        width: 100,
        sortable: true,
        renderer: function qtips(val, p, record) {
            return '<span style="display:table;width=100%;" qtip=\'<div>' + val + '</div>\'>' + record.data.Name + '</span>'
        }
    }, {
        header: '预案级别',
        dataIndex: 'Level',
        width: 100,
        sortable: true
    }, {
        header: '指挥领导',
        dataIndex: 'Leader',
        width: 100,
        sortable: true
    }, {
        header: '参与人数',
        dataIndex: 'PersonNumber',
        width: 100,
        sortable: true
    }, {
        header: '状态',
        dataIndex: 'Status',
        width: 100,
        sortable: true
    }, {
        header: '开始时间',
        dataIndex: 'StartTime',
        width: 100,
        sortable: true
    }, {
        header: '结束时间',
        dataIndex: 'EndTime',
        width: 100,
        sortable: true
    }];
    FantastPlatform.UI.FlowImplementGrid.superclass.constructor.call(this, {
        loadMask: { msg: '正在加载数据...' },
        sm: sm
    });
}

Ext.extend(FantastPlatform.UI.FlowImplementGrid, Ext.grid.GridPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.FlowImplementGrid.superclass.onRender.call(this, ct, position);       
    },
    onAddFlowImplementClick: function () {
        var node = checkGridSelected(this);
        if (node) {
            if (node.length > 1) {
                showErrorMessage("操作失败", "只能选择一个级别进行查看", "");
            } else {
                var lId = node[0].get('LevelId');
                var fId = node[0].get('Id');
                var id = GUID();
                updateTab("流程执行", "EmergencyFlow/FlowImplementPanel.aspx?Id=" + lId + "&flowId=" + fId, 'tabs_Inplement');                
                //= openWind('../EmergencyFlow/FlowImplementForm.aspx?levelId=' + fId, id, '编辑警力分配', 650, 400, null);
            }
        }
    },   
    onSearchClick: function () {
        var id = GUID();
       // currtWind = openWind('../BusinessSearchForm.aspx', id, '查询', 360, 170, 'new_tab');
    },     
    //刷新
    onUpdataFlowImplementClick: function () {
        this.store.removeAll();
        this.store.proxy.conn = { method: 'post', url: this.url };        
        this.store.load({ params: { start: 0, limit: this.paperBar.getPageNumber(), dir: '', sort: ''} });
    }

});
    
